#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Date    : 2017-06-21 10:59:40
# @Author  : mh


'''
Json API definition
'''

import json, logging, inspect, functools


class APIError(Exception):
	'''
	基础api错误类
	'''

	def __init__(self, error, data='', message=''):
		super(APIError, self).__init__(message)
		self.error = error
		self.data = data
		self.message = message


class APIValueError(APIError):
	'''
	valueError 输入内容有误/无效，data返回输入表单错误
	'''

	def __init__(self, field, message=''):
		super(APIValueError, self).__init__('value:invalid', field, message)


class APIResourceNotFoundError(APIError):
	'''
	资源未找到，data返回resource名字
	'''

	def __init__(self, field, message=''):
		super(APIResourceNotFoundError, self).__init__('value:notfound', field, message)


class APIPermissionError(APIError):
	'''
	api无权限？？？？
	'''

	def __init__(self, message=''):
		super(APIPermissionError, self).__init__('permission:forbidden', 'permission', message)
